function fn(nums, k) {
    const map = new Map()
    for (const v of nums) {
        map.set(v, (map.get(v) || 0) + 1)
    }
    let arr = [...map.entries()].sort((a, b) => b[1] - a[1])
    console.log(arr,"000-");
    
    const res = []
    for (let i = 0; i < k; i++) {
        res[i] = arr[i][0]
    }
    return res
}
console.log(fn([1, 1, 1, 2, 2, 3, 3, 3, 3, 0],2));
